<template>
    <div class="index">
        <div class="carousel-main">
            <n-carousel direction="vertical" autoplay dot-placement="right" mousewheel class="carousel">
                <img class="carousel-img" v-for="(item, index) in carouselList" :key="index" :src="item.img">
            </n-carousel>
            <div class="main-essay">
                <div class="essay-item" v-for="(item, index) in [carouselList[0], carouselList[1]]" :key="index">
                    <img class="essay-item-bg" :src="item.img" alt="">
                    <div class="essay-content">
                        <div class="essay-content-icon">推荐</div>
                        <div class="essay-content-title">{{ item.title }}</div>
                    </div>
                </div>
            </div>
        </div>
        <div class="hot-essay">
            <div class="hot-essay-item" v-for="(item, index) in carouselList" :key="index">
                <img class="hot-essay-item-img" :src="item.img" alt="">
                <div class="hot-essay-item-title">{{ item.title }}</div>
            </div>
        </div>
        <n-tabs type="line" animated>
            <n-tab-pane :name="item.title" :tab="item.title" v-for="(item, index) in categoryList" :key="index">
                <Space v-for="item in 5" :key="item" />
            </n-tab-pane>
        </n-tabs>
    </div>
</template>
<script setup lang="ts">
import Space from './essay-space/essay-space.vue'
import { ref } from 'vue';

const carouselList = ref([
    {
        title: '我是第一张图片',
        img: 'https://naive-ui.oss-cn-beijing.aliyuncs.com/carousel-img/carousel1.jpeg',
        desc: '1'
    }, {
        title: '我是第二张图片',
        img: 'https://naive-ui.oss-cn-beijing.aliyuncs.com/carousel-img/carousel2.jpeg',
        desc: '2'
    }, {
        title: '我是第三张图片',
        img: 'https://naive-ui.oss-cn-beijing.aliyuncs.com/carousel-img/carousel3.jpeg',
        desc: '3'
    }, {
        title: '我是第四张图片',
        img: 'https://naive-ui.oss-cn-beijing.aliyuncs.com/carousel-img/carousel4.jpeg',
        desc: '5'
    }
])
const categoryList = ref([
    { id: 1, title: '分类1' },
    { id: 2, title: '分类2' },
    { id: 3, title: '分类3' },
    { id: 4, title: '分类4' },
])
</script>
<style scoped lang="scss">
.index {
    padding: 10px;

    .carousel-main {
        display: flex;
        align-items: center;
        justify-content: space-between;
        height: 340px;

        .carousel {
            width: 69%;
            height: 100%;

            .carousel-img {
                width: 100%;
                height: 100%;
                border-radius: var(--borderRadius);
                object-fit: cover;
            }
        }

        .main-essay {
            width: 30%;
            height: 100%;
            display: flex;
            flex-direction: column;
            justify-content: space-between;

            .essay-item {
                background-color: bisque;
                border-radius: var(--borderRadius);
                // flex: 0 0 48%;
                height: 48.5%;
                position: relative;
                color: var(--fontColor);
                display: flex;
                align-items: flex-end;
                justify-content: flex-start;

                .essay-item-bg {
                    width: 100%;
                    height: 100%;
                    border-radius: var(--borderRadius);
                    position: absolute;
                }

                .essay-content {
                    z-index: 2;
                    position: relative;
                    padding: 5px 10px;
                    display: flex;
                    align-items: center;

                    .essay-content-icon {
                        padding: 1px 8px;
                        background-image: var(--gradientColor1);
                        margin-right: 5px;
                        border-radius: var(--borderRadiusSmall);
                    }
                }
            }
        }
    }

    .hot-essay {
        width: 100%;
        display: flex;
        justify-content: space-between;
        margin-top: 20px;

        .hot-essay-item {
            width: 24%;
            background-color: #F2F6FC;
            border-radius: var(--borderRadius);

            .hot-essay-item-img {
                width: 100%;
                height: 160px;
                border-radius: var(--borderRadius) var(--borderRadius) 0 0;
                display: block;
            }

            .hot-essay-item-title {
                height: 20px;
                padding: 15px 10px;
                display: flex;
                align-items: center;
                color: var(--fontColor2);
                font-weight: var(--fontWeightStrong);
            }
        }
    }
}
</style>